'''
Created on 2010-2-12

@author: summit
'''

from Object import *

class Visitor(Object):
    '''
    An visitor provides the means to access one-by-one all the objects in a
    container and to perform a given operation on those object. This class is the
    base class from which all visitors are derived.
    
    For example:
    How we can declare the PrintingVisitor class which prints an object on the
    console.
    
    class PrintingVisitor(Visitor):
        def visit(self, obj):
            print obj
    
    c = SomeContainer()
    # ...
    c.accept(PrintingVisitor())
    '''


    def __init__(self):
        '''
        Constructor
        '''
        super(Visitor, self).__init__()
    
    def visit(self, obj):
        pass
    
    def getIsDone(self):
        '''
        The isDone property calls the getIsDone accessor to determine whether a
        visitor has finished its work. That is, the getIsDone method returns the
        bool value True if the visitor is done.
        
        For exmaple:
        class SomeContainer(Container):
            for i in self:
                if visitor.isDone:
                    return
                visitor.visit(i)
        '''
        return False
    
    isDone = property(fget=lambda self: self.getIsDone())
        